$(function () {
    Time();
    load();
})

function fh() {
    localStorage.removeItem("chaSH_ID");
    location.href = "../../wen_zhi_yi/mApplySH.html";
}

function Time() {
    var time = new Date();
    var y = time.getFullYear();
    var mon = time.getMonth() + 1; //0-11
    var d = time.getDate();
    var h = time.getHours();
    var m = time.getMinutes();
    var s = time.getSeconds();
    $("#date").val(y + "-" + mon + "-" + d + " " + h + ":" + m + ":" + s);
}

function load() {
    let user = JSON.parse(localStorage.getItem("user"));
    $("#rname").val(user.rname);
    let chaSH_ID = localStorage.getItem("chaSH_ID");
    $("#maID").text(chaSH_ID);
    $.post("/Mapply.do/WZYSHlist", {applyid: chaSH_ID}, function (sdata) {
        let str = " <tr>\n" +
            "           <th>产品编号</th>\n" +
            "           <th>产品名称</th>\n" +
            "           <th>描述</th>\n" +
            "           <th>数量</th>\n" +
            "           <th>出库单编号合集</th>\n" +
            "       </tr>\n";
        $.each(sdata, function (index, item) {
            str +=
                "  <tr>\n" +
                "      <td>" + item.productid + "</td>\n" +
                "      <td>" + item.productname + "</td>\n" +
                "      <td>" + item.productdescribe + "</td>\n" +
                "      <td>" + item.amount + "</td>\n" +
                "      <td></td>\n" +
                "  </tr>";
            $("#name").val(item.register);
            $("#datetime").val(item.registertime);
        })
        $("#tableAdd").html(str);
    })
}

function Submit() {
    let duixiang = {
        "checker": $("#rname").val(),
        "checksuggestion": $("#checksuggestion").val(),
        "checktime": $("#date").val(),
        "checktag": $("[name='zt']:checked").val(),
        "applyid":$("#maID").text()
    };
    $.post("/Mapply.do/WZYSHupdate",duixiang,function (sd) {
        $("#tishi").text("审核成功！")
        $("#tishi").css("color","lime")
        $("#staticBackdrop").modal("show");
    })
}
function hh() {
    localStorage.removeItem("chaSH_ID");
    location.href = "../../wen_zhi_yi/mApplySH.html";
}





